package cn.findviewbydream.evil.main.service.impl;

import cn.findviewbydream.evil.main.dao.WebDao;
import cn.findviewbydream.evil.main.service.WebService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.InitBinder;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


/********************************************
 * 工程名：HebeuCS
 * 包名：cn.findviewbydream.evil.main.service.impl
 * 时间：16-12-5
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：WebService实现类
 ********************************************/
@Service("webService")
public class WebServiceImpl implements WebService
{
    private Logger logger = LoggerFactory.getLogger(WebServiceImpl.class);

    private final WebDao webDao;

    @Autowired
    public WebServiceImpl(WebDao webDao) {this.webDao = webDao;}

    @Override
    public int autoSelect()
    {
        return webDao.selectUserCount();
    }

    @Override
    public int getAccessTimes()
    {
        return webDao.selectAccessTimes();
    }

    @Override
    public boolean setAccessTimes(int times)
    {
        try
        {
            return webDao.updateAccessTimes(times) == 1;
        }
        catch (Exception e)
        {
            logger.error(e.toString());
            return false;
        }
    }
}
